let search=window.location.search.split('=')[1]

if(search==undefined||search==''){
    let tagVessels=document.querySelector('.tagVessels')
    tagVessels.innerHTML+=`
        <div class="userEmpty">没有查到相关专辑</div>
    `
}else{
    //返回总数
    function pictureSearch(pageNo){
        return new Promise((reslove,reject)=>{
            axios({
                url:'/picture/searchAlbumByName',
                params:{
                    name:search,
                    pageNo:pageNo||1,
                    pageSize:6
                }
            }).then(data=>{
                let message=data.data.key.data
                reslove(message)
            }).catch(err=>{
                reject(err)
            })
        })
    }
    let size=1;
    //遍历图片信息
    let tagVessels=document.querySelector('.tagVessels')
    function pictureMessage(size){
        pictureSearch(size).then(data=>{
            if(data==null){
                tagVessels.innerHTML+=`
                    <div class="userEmpty">没有查到相关专辑</div>
                `
            }else{
                let message=data.list
                if(message.length==0){
                    tagVessels.innerHTML+=`
                        <div class="userEmpty">没有查到相关专辑</div>
                    `
                }else{
                    for(let i=0,len=message.length;i<len;i++){
                        let messagei=message[i]
                        tagVessels.innerHTML+=`
                        <div class="pictureV" onclick=toAlbum(${messagei.id})>
                            <div class="pictureVs">
                                <div class="picture" style="background-image: url(${messagei.cover});"></div>
                                <div class="userVessels">
                                    <div class="userName">${messagei.name}</div>
                                </div>
                            </div>
                        </div>
                        `
                    }
                    let node=tagVessels.lastElementChild
                    let io=new IntersectionObserver(config=>{
                        if(config[0].intersectionRatio>0){
                            //停止观察
                            io.disconnect()
                            if(size*6<data.total){
                                size++
                                pictureMessage(size)
                            }
                        }
                    })
                    io.observe(node)
                }
            }
        }).catch(err=>{
            console.log(err);
        })
    }
    pictureMessage(size)
}

function toAlbum(id){
    window.location.href = `/picture/personmainpage?albumId=${id}`
}